<?php
/**
 * While
 *
 * While loops are the simplest type of loop in GOP scripting language.
 *
 * @author  Badrus Said <badrus.said@gmail.com>
 * @since   gop1.0
 */
final class gop_While extends gop_BaseIterator {
    public function execute(gop_Base $_caller = null) {
        $this->setCaller($_caller);
        $cond = $this->getContext()->getCallee($this->expression);
        $cond->execute($this);
        while($this->getResult()) {
            $this->getContext()->getCallee($this->ifTrue)->execute($this);
            if ($this->getContinue()) {
                $this->interuptContinue();
                continue;
            }
            if ($this->getBreak()) {
                $this->interuptBreak();
                break;
            }
            if ($this->getReturn()) return;
            $cond->execute($this);
        }
        $this->chainExec();
    }
}
?>